home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / misc / emu / ATUtilities.lha / ATUtilities / smus.c < prev    next >
C/C++ Source or Header  |  2000-09-26  |  2KB  |  103 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <libraries/dos.h>
  4.  
  5. struct SScoreHeader
  6. {
  7.  UWORD tempo;
  8.  UBYTE volume;
  9.  UBYTE ctTrack;
  10. } *sh;
  11.  
  12. struct RefInstrument
  13. {
  14.  UBYTE reg;
  15.  UBYTE type;
  16.  UBYTE data1,data2;
  17.  char  name[];
  18. } *ri;
  19.  
  20. struct FileHandle *fh;
  21. UBYTE              mem[4096];
  22. ULONG              ChunkLen;
  23. LONG               i,j,k,l;
  24. UBYTE              FoundChunk;
  25. UBYTE             *Track[50];
  26. ULONG              TrackLen[50];
  27. UBYTE              tc;
  28.  
  29. VOID main()
  30. {
  31.  fh=Open("DH0:Musik/Aegis Sonix/Scores/The End.smus",MODE_OLDFILE);
  32.  if(fh!=NULL)
  33.   {
  34.    Read(fh,&mem,12);
  35.    if(!(strncmp(&mem,"FORM",4)))
  36.     {
  37.      if(!(strncmp(&mem[8],"SMUS",4)))
  38.       {
  39.        printf("Reading IFF-SMUS file...\n");
  40.       }
  41.      tc=0;
  42.      /* -------------------------------------------------------------- */
  43.  
  44.      i=Read(fh,&mem,8);
  45.      while(i==8)
  46.       {
  47.        ChunkLen=mem[4]*16777216+mem[5]*65536+mem[6]*256+mem[7];
  48.        FoundChunk=FALSE;
  49.  
  50.        if(!(strncmp(&mem,"SHDR",4)))
  51.         {
  52.          FoundChunk=TRUE;
  53.          sh=&mem;
  54.          Read(fh,sh,ChunkLen);
  55.          printf("Header:\n");
  56.          printf("  Tempo:   %ld\n",sh->tempo);
  57.          printf("  Volume:  %ld\n",sh->volume);
  58.          printf("  ctTrack: %ld\n",sh->ctTrack);
  59.         }
  60.        else if(!(strncmp(&mem,"INS1")))
  61.         {
  62.          FoundChunk=TRUE;
  63.          ri=&mem;
  64.          Read(fh,ri,ChunkLen);
  65.          mem[ChunkLen]=0x00;
  66.  
  67.          printf("Instrument %ld: %s\n",ri->reg,&ri->name);
  68.         }
  69.        else if(!(strncmp(&mem,"TRAK")))
  70.         {
  71.          FoundChunk=TRUE;
  72.          Track[tc]=AllocMem(ChunkLen,MEMF_CLEAR|MEMF_PUBLIC);
  73.          if(Track[tc]!=NULL)
  74.           {
  75.            Read(fh,Track[tc],ChunkLen);
  76.            TrackLen[tc]=ChunkLen;
  77.           }
  78.          else exit(0);
  79.          printf("Track #%ld  %ld Bytes\n",tc,ChunkLen);
  80.          tc++;
  81.         }
  82.  
  83.        if(FoundChunk==FALSE)
  84.         {
  85.          printf("%c%c%c%c\n",mem[0],mem[1],mem[2],mem[3]);
  86.          Seek(fh,ChunkLen,OFFSET_CURRENT);
  87.         }
  88.  
  89.        if(ChunkLen & 1) Seek(fh,1,OFFSET_CURRENT);
  90.        i=Read(fh,&mem,8);
  91.       }
  92.      /* -------------------------------------------------------------- */
  93.  
  94.     }
  95.    for(i=0;i<10;i++)
  96.     {
  97.      if(Track[i]!=NULL) FreeMem(Track[i],TrackLen[i]);
  98.     }
  99.    Close(fh);
  100.   }
  101. }
  102.  
  103.